import Vue from 'vue'
import App from './App'
import './uni.promisify.adaptor'
import uView from 'uview-ui'
import store from '@/store/index'

Vue.use(uView)
Vue.prototype.$onLaunched = new Promise(resolve => {
	Vue.prototype.$isResolve = resolve
})
Vue.prototype.$store = store
Vue.config.productionTip = false

uni.$u.config.unit = 'rpx'
App.mpType = 'app'
Vue.prototype.ScanAudio = function() {
	const backgroundAudioManager = uni.getBackgroundAudioManager()
	  backgroundAudioManager.title = '测试后台播报';
	  backgroundAudioManager.epname = '测试后台播报';
	  backgroundAudioManager.singer = '测试后台播报';
	  backgroundAudioManager.coverImgUrl = '';
	  // 设置了 src 之后会自动播放
	  backgroundAudioManager.src = 'http://linghuo-app.oss-cn-chengdu.aliyuncs.com/7/58CC188F587C421297E41D664DAC6EA7.mp3';
	  //播放开始触发onEnded方法
	  backgroundAudioManager.onPlay(() => {
	        console.log("音乐播放开始");
	  })
	  //播放结束触发onEnded方法
	  backgroundAudioManager.onEnded(() => {
	        console.log("音乐播放结束");
	  })
	  backgroundAudioManager.onError(() => {
	      console.log("音乐播放错误");
	  })
	  
	  
	  
	  
	// const innerAudioContext = uni.createInnerAudioContext();
	// innerAudioContext.autoplay = true;
	// innerAudioContext.volume = 1
	// innerAudioContext.src = 'http://linghuo-app.oss-cn-chengdu.aliyuncs.com/7/58CC188F587C421297E41D664DAC6EA7.mp3';
	// innerAudioContext.onPlay(() => {
	// 	console.log('开始播放');
	// });
	// innerAudioContext.onError((res) => {
	// 	console.log(res.errMsg);
	// 	console.log(res.errCode);
	// });
}
// Vue.prototype.$onLaunched = new Promise(resolve => {
//     Vue.prototype.$isResolve = resolve
// })
const app = new Vue({
	...App
})
app.$mount()